package org.game.db.proxy.bean;

import org.cfg.DungeonLevelCfg;
import org.cfg.DungeonLevelGroupCfg;
import org.cfg.cache.DungeonLevelCfgCache;
import org.cfg.cache.DungeonLevelGroupCfgCache;
import org.game.db.bean.DungeonLevel;

import com.sojoys.artifact.build.data.base.BasePojoProxy;
import org.game.db.bean.DungeonLevelGroup;
import org.game.db.cache.DungeonLevelGroupCache;
import org.utils.TimeUtil;

import java.util.Date;

/**
 * @author : DengYing
 * @CreateDate : 2017年11月30日 下午2:42:29
 * @Description ：Please describe this document
 */
public class DungeonLevelProxy extends BasePojoProxy<DungeonLevelProxy, DungeonLevel> {
    public DungeonLevelCfg getCfg() {
        return DungeonLevelCfgCache.me().getById(t.getCid());
    }

    /**
     * 获取副本组配置
     */
    public DungeonLevelGroupCfg getLevelGroupCfg() {
        return DungeonLevelGroupCfgCache.me().getById(getCfg().getLevelGroupId());
    }

    public int getDungeonLevelGroupCid() {
        return getCfg().getId();
    }

    public boolean refreshFightCount(long now){
        if (t.getLastRefreshTime()!= null && TimeUtil.isSameDay(t.getLastRefreshTime().getTime(),now)){
            return false;
        }
        t.setLastRefreshTime(new Date());
        t.setFightCount(0);
        t.update();
        return true;
    }

}
